public int[][] getNearLess(int[] arr){
    int[][] res=new int[arr.length][2];
    Stack<List<Integer>> stack=new Stack<>();
    for(int i=0;i<arr.length;i++){
        while(!stack.isEmpty()&&arr(stack.peek.get(0)>arr[i])){
            List<Integer> popIs=stack.pop();
            int leftLessIndex=stack.isEmpty()?-1:stack.peek.get(stack.peek.size()-1);
            for(Integer popIndex:popIs){
                res[popIndex][0]=leftLessIndex;
                res[popIndex][1]=i;
            }

        }

    if(!stack.isEmpty()&&arr(stack.peek.get(0)==arr[i])){
        stack.peek().add(Integer.valueOf(i));
    }else{
        ArrayList<Integer> list=new ArrayList<>();
        list.add(i);
        stack.push(list);
    }
    }

    while(!isEmpty()){
        List<Integer> list=new ArrayList<>();
        int leftLessIndex=stack.isEmpty()?-1:stack.peek.get(stack.peek.size()-1);
         for(Integer popIndex:popIs){
                res[popIndex][0]=leftLessIndex;
                res[popIndex][1]=-1;
            }
    }
    return res;
}